<SCRIPT LANGUAGE="JavaScript">  
    function validation()
    {
        updateRTEs();
        document.getElementById('ApplicantCover').value=document.getElementById('hdnrtecover').value;
        var temp="";
        temp=document.getElementById('ApplicantCover');
        if( temp.value.length < 40 )
        {
            temp.focus();
            temp.style.backgroundColor='#FF9';
            alert('Please provide cover letter');
            temp.style.backgroundColor='#FFF';
            return false;             
        }
    }        
    function gocover()
    {
        if (confirm('Are you sure you want to continue the action ?\nIf you think the template is not suitable for you, you can undo the change at the editor.'))
        {
            var isi=document.getElementById('company_name').value+"<br/><br/>"+document.getElementById('now').value+"<br/><br/>To Whom It May Concern:<br/><br/>Application for the position of "+document.getElementById('position').value+" <br/><br/>I am interested in applying for the above position advertised in ITjobz.com on "+document.getElementById('created').value+". My resume is attached for your review.<br/><br/>I am confident that my skills and past experience could make great contributions to your organization. Therefore I would appreciate the opportunity to discuss my qualifications for this position in greater detail with you in person at your earliest convenience.<br/><br/>Thank you for your consideration and I look forward to hearing from you.<br/><br/>Yours sincerely,<br/>"+document.getElementById('first_name').value+" "+document.getElementById('last_name').value+"<br/>";
            frames['rtecover'].document.body.innerHTML=isi;
        }
    }   
    initRTE("../../app/webroot/js/images/", "../../app/webroot/js/", "../../app/webroot/js/");    
        
</SCRIPT>
<?php
echo "<div class='form'>";
echo "<h2> Appliying Job </h2>";
echo "<hr color='#2A7EF7'>";


        if( $jobseeker['jobseekers']['city_id']!=$job['jobs']['city_id'] || $jobseeker['resumes']['academic_id']<$job['jobs']['academic_id'] )
        {
            echo "<span class='red'>WARNING!!</span>";
            if( $jobseeker['jobseekers']['city_id']!=$job['jobs']['city_id'] )
            { echo "<br>:. <span class='info'>Your residence and the job's location are different</span>";  }
            if( $jobseeker['resumes']['academic_id']<$job['jobs']['academic_id'] )
            { echo "<br>:. <span class='info'>Your qualification level is not properly sufficient</span>";  }

        }

        echo "<div class='kotak2'>"; 
        echo $form->create('Applicant',array('action'=>'apply','onsubmit'=>'return validation();'));
        
            echo $this->element('myfunction');
            $complete = $this->requestAction(array('controller'=>'jobseekers','action'=>'complete_all')); 
            
            if($jobseeker['resumes']['upload_file']=='' && !$complete)
            { echo "<center><b><font style='color:red;font-size:120%;'>WARNING!!!</font><br> you haven't create neither your resume online or attachment resume</b></center>"; }
            
            echo "<div class='input'><label>To</label>  <input type='text' value='".$job['employers']['company_name']."' disabled=true size='30'></div>";
            echo "<div class='input'><label>Job's Position</label>  <input type='text' value='".$job['jobs']['position']."' disabled=true size='30'></div>";
            
            echo "<div class='input'><label>Resume Attach</label>";  
        
            if($complete)
            { echo  "<input type='radio' id='status' name='data[Applicant][resume]' value='0' checked=true> Resume online<br>"; }
            else 
            { echo  "<input type='radio' id='status' name='data[Applicant][resume]' value='0' disabled='true'><font color='#aaa'> Resume online </font><br>"; } 
            
            if($jobseeker['resumes']['upload_file']!='')
            { 
                if($complete)
                { echo  "<label> &nbsp </label><input type='radio' id='status' name='data[Applicant][resume]' value='1' > Resume Attachment<br>"; }
                else
                { echo  "<label> &nbsp </label><input type='radio' id='status' name='data[Applicant][resume]' value='1' checked=true> Resume Attachment<br>"; }
            }
            else
            { echo  "<label> &nbsp </label><input type='radio' id='status' name='data[Applicant][resume]' value='1' disabled='true'><font color='#aaa'> Resume Attachment </font><br>"; }
            
            echo "</div>";
            echo $form->input('jobseeker_id',array('type'=>'hidden'));
            echo $form->input('job_id',array('type'=>'hidden'));
            echo $form->input('cover',array('type'=>'hidden'));
            
            echo "<input type='hidden' id='company_name' value='<b>".$job['employers']['company_name']."</b>'>";
            echo "<input type='hidden' id='position' value='<b>".$job['jobs']['position']."</b>'>";
            echo "<input type='hidden' id='created' value='".mydate($job['jobs']['created'])."'>";
            echo "<input type='hidden' id='now' value='".mydate(date("Y-m-d"))."'>";
            echo "<input type='hidden' id='first_name' value='".$jobseeker['jobseekers']['first_name']."'>";
            echo "<input type='hidden' id='last_name' value='".$jobseeker['jobseekers']['last_name']."'>";
        
        echo "<div class='input'><label> Cover Letter </label><input type='button' value='Load Example' onClick='gocover();'>";
        echo "</div>";
        
        echo "<center><div style='background-color:white'>";
?>
<SCRIPT language="JavaScript" type="text/javascript">
    writeRichText('rtecover', '', 400, 200, true, false);
</SCRIPT>

<?php 
        echo "</div></center>";
        echo "<div class='input'><label>&nbsp</label>";
            if($jobseeker['resumes']['upload_file']!='' || $complete)
            { echo "<input type='submit' value='Apply'"; }
            else
            { echo "<input type='submit' value='Apply' disabled='true'>"; }
        echo "</div>";
    echo "</form>";
    echo "</div>";
echo "</div>";
?>
